package adv2;

import java.util.*;

public class YuangongMap {
	// 非常重要
	public static void main(String[] args) {
		Map map = new HashMap();// 存放员工对象及其职务
		map.put(new Yuangong("小吴", 22, "男", "副总", 19000, "hf001"), "副总");
		map.put(new Yuangong("小张", 23, "男", "门卫", 19000, "hf002"), "门卫");
		map.put(new Yuangong("老刘", 29, "男", "司机", 19000, "hf003"), "司机");
		map.put(new Yuangong("老宋", 32, "男", "办公室主任", 19000, "hf004"), "主任");
		map.put(new Yuangong("王莽", 52, "男", "安汉公", 1900000, "hf003"), "皇帝");

		System.out.println(map.size());// ?4
		System.out.println(map);
		System.out.println(">>>>>>>>>");
		Set sk = map.keySet();
		for (Object o : sk)
			System.out.println(o);
		System.out.println(">>>>>>>>>迭代>>>>>>>>>>>>>>>>>");
		Iterator ir = sk.iterator();
		while (ir.hasNext()) {
			Object key = ir.next();
			Object value = map.get(key);
			System.out.println("key=" + key + ",值=" + value);
		}
		System.out.println(">>>>>>>>>迭代方案2>>>>>>>>>>>>>>>>>");
		for (Object o : sk) {
			Object value = map.get(o);
			System.out.println("key=" + o + ",值=" + value);
		}
	}
}
